import Vue from 'vue';
import VueRouter from 'vue-router';
import {Message} from 'element-ui';

Vue.use(VueRouter);

// 解决相同路径重复跳转的问题
// console.log(VueRouter.prototype);
const VueRouterPush = VueRouter.prototype.push;
const VueRouterReplace = VueRouter.prototype.replace;
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => {
        Message.error(err);
    });
}
VueRouter.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => {
        Message.error(err);
    });
}

const routes = [
    {
        path: '/',
        name: 'index',
        component: () => import('../views/index.vue')
    },
    {
        path: '/chartViews',
        name: 'chartViews',
        component: () => import('../views/chartViews.vue')
    },
];
const router = new VueRouter({
    // mode: "history",
    mode: "hash",
    routes
})

export default router